import "package:flutter/material.dart";
import 'package:flutter_app/components/fixed-channel.dart';
import 'package:flutter_app/components/fixed-list.dart';
import 'package:flutter_app/components/topStack.dart';
import 'package:flutter_app/components/layout.dart';
import 'package:flutter_app/generated/l10n.dart';
class FixedIncome extends StatefulWidget {
  @override
  _FixedIncomeState createState() => _FixedIncomeState();
}
class ListItem {
  String title;
  String url;
  ListItem({this.title, this.url });
}

List<ListItem> LIST_DATA = [
  ListItem(title: 'USDT 【M站两周年欢庆专享】', url:'/fixed/detail'),
  ListItem(title: 'USDT', url:'/fixed/detail'),
  ListItem(title: 'USDC', url:'/fixed/detail'),
  ListItem(title: 'BTC', url:'/fixed/detail'),
  ListItem(title: 'BCH', url:'/fixed/detail'),
  ListItem(title: 'ETH', url:'/fixed/detail'),
];

class _FixedIncomeState extends State<FixedIncome> {
  List<ChannelInfo> channel_infos=List(6);
  ChannelInfo _channelInfo;
  _onSelectChannel(ChannelInfo c) async {
    setState(() {
      _channelInfo = c;
    });
  }
  @override
  Widget build(BuildContext context) {
     channel_infos = [
      ChannelInfo(id: 'all', name: S.of(context).all),
      ChannelInfo(id: 'USDT', name: 'USDT'),
      ChannelInfo(id: 'USDC', name: 'USDC'),
      ChannelInfo(id: 'BTC', name: 'BTC'),
      ChannelInfo(id: 'BCH', name: 'BCH'),
      ChannelInfo(id: 'ETH', name: 'ETH'),
    ];
     _channelInfo = channel_infos.first;
    return Scaffold(
        appBar: AppBar(
          brightness: Brightness.dark,
          backgroundColor: Colors.blueAccent[400],
          elevation: 0,
        ),
        body: SafeArea(
            child: Column(children: [
              TopStack(
              children: [
                Image.asset('assets/images/ic_product_list_time_deposit.png',
                    width: 50),
                SizedBox(
                    width:15
                ),
                Expanded(
                  child: ColumnStart(
                    children: [
                      ColumnStart(
                        children: [
                          Text(
                            '固收投资',
                            style: TextStyle(fontSize: 18),
                          ),
                          SizedBox(
                            height: 8,
                          ),
                          Text(
                            '资产真实，收益稳健',
                            style: TextStyle(
                                fontSize: 14, color: Colors.grey),
                          ),
                          SizedBox(
                            height: 8,
                          ),
                        ],
                      ),
                      Container(
                        padding: EdgeInsets.symmetric(vertical: 10.0),
                        decoration: BoxDecoration(
                            border: Border(
                              top: BorderSide(
                                width: 1, //宽度
                                color:
                                Colors.grey.withOpacity(0.2), //边框颜色
                              ),
                            )),
                        child: GestureDetector(
                          onTap: () => Navigator.pushNamed(context, '/fixed/record'),
                          child: Row(
                            mainAxisAlignment:
                            MainAxisAlignment.spaceBetween,
                            children: [
                              Expanded(
                                child: Text(
                                  //invest_record 投资记录
                                  S.of(context).invest_record,
                                  style: TextStyle(fontSize: 16),
                                ),
                              ),
                              Icon(
                                Icons.arrow_forward_ios,
                                color: Colors.grey.withOpacity(0.5),
                                size: 16,
                              )
                            ],
                          ),
                        ),
                      )
                    ],
                  ),
                )
              ],
          ),
          FixedChannel(
            channelInfo: _channelInfo,
            onSelectChannel: _onSelectChannel,
            channel_infos:channel_infos
          ),
          SizedBox(
            height: 20,
          ),
          FixedList(data: LIST_DATA,onRefresh: ()=>{},
            loadMore: ()=>{},)
        ])
        ),
    );
  }
}
